package com.google.jguery.client.query;

import java.util.HashSet;
import java.util.Set;

import com.google.jguery.client.common.FieldText;

/**
 * This feels like to be a composition than a extension/child.
 * for the moment, make it abstract to keep away unwanted behavior
 * @author cxu
 *
 */
public abstract class CompoundQuery extends Query {

	Set<Query> subQueries = new HashSet<Query>();

	@Override
	public Query normalize() {
		// TODO need to build this
		return null;
	}

	@Override
	public void allTerms(Set<FieldText> termSet) {
		for (Query query : subQueries) {
			query.allTerms(termSet);
		}
	}

	@Override
	public void existingTerms(Searcher searcher, Set<FieldText> termSet,
			boolean reverse) {
		for (Query q: subQueries) {
			q.existingTerms(searcher, termSet, reverse);
		}		
	}
}
